import VueRouter from "vue-router"
import vue from "vue"
import Home from "@/pages/Home"
import About from "@/pages/About"
import News from "@/pages/Home/compoents/News"
import Message from "@/pages/Home/compoents/message"
import msg from '@/pages/Home/compoents/compoent/msg'
import news from '@/pages/Home/compoents/compoent/News'
let reWritePush=VueRouter.prototype.push
VueRouter.prototype.push=function(config){
    return reWritePush.call(this,config).catch(()=>{})
}
vue.use(VueRouter)
export default new VueRouter({
    linkActiveClass:"active",
    routes: [
        {
            path: "/home",
            component: Home,
            children: [
                {
                    path: "/home/news",
                    component: News,
                    children:[
                        {   
                            name:"ItemNews",
                            path:"ItemNews/:id",
                            component:news,
                            props:(route)=>{
                                return {
                                    id:route.params.id,
                                    title:route.query.title
                                }
                            }
                        }
                    ]
                },
                {
                    path: "/home/message",
                    component: Message,
                    children:[
                        {
                            path:"msg/:id",
                            component:msg,
                            props:(route)=>{
                                return {
                                    id:route.params.id
                                }
                            }
                        }
                    ]
                },
                {
                    path:"/home",
                    redirect:"/home/message"
                }
            ]
        },
        {
            path: "/about",
            component: About
        },
        {
            path: "/",
            redirect: "/home"
        }
    ]
})